<template>
	<div id="login-entry-container">
		<div class="login-entry-box">
			<Input class="login-entry-input" v-model="sid" placeholder="学号" />
			<Input class="login-entry-input" v-model="password" type="password" password placeholder="密码" />
			<Button type="default" ghost @click="entry()">登录</Button>
		</div>
	</div>
</template>

<script>
import stuRequest from '@/axios/student';

export default {
	data() {
		return {
			sid: "",
			password: ""
		}
	},
	methods: {
		async entry() {
			if (this.sid.length != 12 || isNaN(this.sid)) {
				this.$Message.warning("请输入正确的学号");
				return;
			}
			if (/[\u4E00-\u9FA5\uF900-\uFA2D]/.test(this.password) || this.password.length < 6) {
				this.$Message.warning("请输入正确的密码");
				return;
			}
			let res = await stuRequest.entry(this.sid, this.password);
			if (res != undefined) {
				this.$store.state.user = res;
				this.$jspt.addMenu(this.$store.state.user);
				this.$jspt.axiosStudent();
				this.$router.replace("/home");
			}
		}
	}
}
</script>

<style lang="scss">
@import "@login/scss/entry-index.scss";
</style>